package com.itheima.controller;  
 2  
 3 import com.domain.Book;  
 4 import com.itheima.service.BookService;  
 5 import org.springframework.beans.factory.annotation.Autowired;  
 6 import org.springframework.stereotype.Controller;  
 7 import org.springframework.web.bind.annotation.RequestMapping;  
 8 import org.springframework.web.servlet.ModelAndView;  
 9  
 10 @Controller  
 11 public class BookController {  
 12 @Autowired  
 13 BookService bookService;  
 14 @RequestMapping("/book")  
 15 public ModelAndView book(Integer id){  
 16 Book book = bookService.findBookById(id);  
 17 ModelAndView modelAndView = new ModelAndView();  
 18 modelAndView.setViewName("book");  
 19 modelAndView.addObject("book",book);  
 20 return modelAndView;  
 21 }  
 22 } 